var _contextPath;
var sellerCode = "";
$(document).ready(function() {
	list();
	top.UppTabs.operator = top.getCurrentTagTitle();// 设置用户tab的标题值
	});
/**
 * 查询用户列表
 */
function list() {
	_contextPath = $("#contextPath").val();

	var merchantEncode = $("#merchantEncode").val();
	// alert("merchantEncode:"+merchantEncode);
	var cardType = ""
	var s = "";
	var e = "";
	var isAccount = ""

	$("#merchant_expensive_record_list").datagrid( {
		onLoadError : function() {
			// uppAjaxError(data);
	},
	queryParams : {
		cardType : cardType,
		isAccount : isAccount,
		beginTime : s,
		endTime : e
	},
	columns : [ [ {
		field : 'recordId',
		title : '',
		hidden : true
	}, {
		field : 'cardNum',
		title : '卡编码',
		width : 100
	}, {
		field : 'cardType',
		title : '卡类型',
		width : 100,
		formatter : function(value, row, index) {
			if (value == '0') {
				return '套餐卡';
			} else if (value == '1') {
				return '充值卡';
			}
		}
	}, {
		field : 'expenseAmount',
		title : '金额(元)',
		width : 100
	}, {
		field : 'expenseTime',
		title : '刷卡时间',
		width : 100,
		align : 'center',
		formatter : function(value, row, index) {
			return (new Date(Number(value))).dateConvert();
		}
	}, {
		field : 'isAccount',
		title : '结算状态',
		width : 100,
		formatter : function(value, row, index) {
			if (value == '0') {
				return '未结算';
			} else if (value == '1') {
				return '已结算';
			}
		}
	} ] ],
	autoRowHeight : true,
	fitColumns : true,
	pagination : true,
	singleSelect : true,
	rownumbers : true
	});
}

function getContextPath() {
	if ("" == _contextPath) {
		_contextPath = $("#contextPath").val();
	}
	return _contextPath;
}

/**
 * 搜索
 * 
 * @return
 */
function searchKey() {
	var s = $('input[name="beginTime"]').val();
	var e = $('input[name="endTime"]').val();
	if (s == "" && e != "") {
		top.uppShow('请选择开始时间！');
		return;
	}
	if (s != "" && e == "") {
		top.uppShow('请选择结束时间！');
		return;
	}
	if (s > e) {
		top.uppShow('开始时间大于了结束时间，请重新选择!');
		return;
	}
	var cardType = $("#cardType").val();
	var isAccount = $("#isAccount").val();

	// var sellerCode = $("#sellers").val();
	// top.uppShow(s + " | " + e + " | " + cardType + " | " + isAccount + " | "
	// + sellerCode);

	$('#merchant_expensive_record_list').datagrid('load', {
		isAccount : isAccount,
		cardType : cardType,
		beginTime : s,
		endTime : e
	});
}
